//package ficus.suitcase.dynamicload;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.DisposableBean;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//
///**
// * @author DamonFicus
// */
//public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
//    private static ApplicationContext applicationContext = null;
//    private static Logger logger = LoggerFactory.getLogger(SpringContextHolder.class);
//
//    public SpringContextHolder() {
//    }
//
//    public static ApplicationContext getApplicationContext() {
//        return applicationContext;
//    }
//
//    public static <T> T getBean(String name) {
//        return (T) applicationContext.getBean(name);
//    }
//
//    public static <T> T getBean(Class<T> requiredType) {
//        return applicationContext.getBean(requiredType);
//    }
//
//    public static void clearHolder() {
//        logger.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
//        applicationContext = null;
//    }
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) {
//        logger.debug("注入ApplicationContext到SpringContextHolder:{}", applicationContext);
//        if(SpringContextHolder.applicationContext != null) {
//            logger.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
//        }
//
//        SpringContextHolder.applicationContext = applicationContext;
//    }
//
//    @Override
//    public void destroy() throws Exception {
//        clearHolder();
//    }
//}
